<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/6 0006
 * Time: 17:04
 */
namespace app\modules\content\controllers;

use app\libs\Pager;
use yii;
use app\libs\ApiControl;
use app\modules\content\models\Teachers;
use app\libs\GetData;

class LogController extends ApiControl
{
    public $enableCsrfValidation = false;

    public function actionIndex()
    {
        $pagesize=20;
        $page = Yii::$app->request->get('page', 1);
        $offset = $pagesize * ($page - 1);
        $count = Yii::$app->db->createCommand("select count(*) as count from {{%login_log}} ")->queryOne();
        $data = Yii::$app->db->createCommand("select l.*,a.userName from {{%login_log}} l left join {{%admin}} a on l.adminId=a.id order by id desc limit $offset,$pagesize")->queryAll();
        $url = '/content/log/index?page';
        $count = $count['count'];
        $page = new Pager("$url", $count, $page, $pagesize);
        $str = $page->GetPager();
        return $this->render('index', ['data' => $data, 'str' => $str]);
    }
}